]> dgit.raspbian.org Git - ostree.git/commitdiff
repo: Fix validation for min-free-space-percent config option
authorwangzhaohui <wangzhaohui@uniontech.com>
Wed, 24 Jun 2026 01:00:47 +0000 (09:00 +0800)
committerwangzhaohui <wangzhaohui@uniontech.com>
Wed, 24 Jun 2026 01:00:47 +0000 (09:00 +0800)
Add explicit validation that the string contains only digits before
converting to a number. This ensures invalid values are rejected with
a clear error message.

Fixes: https://github.com/ostreedev/ostree/issues/3274
src/libostree/ostree-repo.c

index f20611b4b7d5254d106863c50725d0fc06f38cff..e366cda158f6f95f204a27df590dac9f670dd2c5 100644 (file)
@@ -3176,6 +3176,14 @@ reload_core_config (OstreeRepo *self, GCancellable *cancellable, GError **error)
                                                 NULL, &min_free_space_percent_str, error))
           return FALSE;
 
+        /* Validate that the string contains only digits */
+        for (const char *p = min_free_space_percent_str; *p; p++)
+          {
+            if (!g_ascii_isdigit (*p))
+              return glnx_throw (error, "Invalid min-free-space-percent '%s': must be a number",
+                                 min_free_space_percent_str);
+          }
+
         self->min_free_space_percent = g_ascii_strtoull (min_free_space_percent_str, NULL, 10);
         if (self->min_free_space_percent > 99)
           return glnx_throw (error, "Invalid min-free-space-percent '%s'",